//
//  DeliveryPartsListCell.m
//  FactorySale
//
//  Created by 主事丫环HU on 2020/7/31.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "DeliveryPartsListCell.h"
#import "SYBigImage.h"
@interface DeliveryPartsListCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *partsNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;
@property (weak, nonatomic) IBOutlet UILabel *unitLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@end
@implementation DeliveryPartsListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    
    static NSString *ID = @"DeliveryPartsListCell";
    
    DeliveryPartsListCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        
        cell = [NSBundle.mainBundle loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].firstObject;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)setModel:(UnpaidOrHistoryRelListModel *)model{
    
    __weak typeof(self) _weakSelf = self;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.attributeLogo] placeholderImage:imgname(GOODS_PLACE_HOLDER) completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        if (image && cacheType == SDImageCacheTypeNone) {
            _weakSelf.iconImageView.alpha = 0;
            [UIView animateWithDuration:1.0 animations:^{
                _weakSelf.iconImageView.alpha = 1.0f;
            }];
        } else {
            _weakSelf.iconImageView.alpha = 1.0f;
        }
    }];
    SYBigImage * bigI = [[SYBigImage alloc]init];
    [self.iconImageView addGestureRecognizer:bigI];
    self.iconImageView.userInteractionEnabled = YES;
    
    self.partsNameLabel.text = model.name;
    self.countLabel.text = model.send_count;
    self.unitLabel.text = model.unit;
    self.priceLabel.text = [NSString stringWithFormat:@"单价：¥ %@",model.salePrice];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
